Function Overloading in C# .Net

Ratings:
(4)
Views: 505
Banner-Img
Share this blog:

 

Function Overloading

Function overloading is a concept of writing more than one function with the same name and with different types of arguments.

 Observations

Proto type possible to overload
Public void Print () 1 & 2  Not possible
Private Void Print () 1 & 3 Not possible
Public int Print ()  1& 4 Yes
Public void Print (Int x)  4 & 5 NO
Public void Print (int y)  4 & 6   Yes 
Public void Print (ref int x) 4 & 7  Yes
Public Void Print  (out int x)  6 & 7 No
Public void Print  ()  1 &8  Yes [Not overloading concept]

 These core tutorials will help you to learn the fundamentals of .NET. For an in-depth understanding and practical experience, explore Online ".NET Training".

Example on function overloading

Open Window forms Application Project Place a Button Code in GD

 Class Test

{

Public void print  ( float x)

{

Message. Box. Show  (“From float :”  + X);

}

Public void Print  (double X)

{

Message. Box. Show  (“From double:”  + X);

}

Public void Print  (decimal X)

{

Message. Box. Show  (“From decimal:”  + X);

}

}

//test   Code for button1_click   Test t = new Test ();  

Print (4.0) ;//
//t. Print (4); error

Print (4f);//float
Print (4m);//decimal
Print (4d);//double
       

You liked the article?

Like: 0

Vote for difficulty

Current difficulty (Avg): Medium

EasyMediumHardDifficultExpert
IMPROVE ARTICLEReport Issue

About Author

Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox